﻿// JSON C# Class Generator
// http://at-my-window.blogspot.com/?page=json-class-generator

using System;
using Newtonsoft.Json.Linq;
using JsonCSharpClassGenerator;
using TomatoSynchronizer.Store;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace TomatoSynchronizer.Entities 
{

    public class Faq 
    {

    	public override bool Equals(object obj)
		{
			if(obj is Faq)
			{
				Faq faq = (Faq)obj;
				
				if(faq.faqs_order  == _faqs_order && faq.faqs_status == _faqs_status)
				{
					MappingStore mappingStore = new MappingStore(store.site,faq.store.site,"languages_id");
					
					foreach(Mapping mapping in mappingStore.Mappings)
					{
						try
						{							
							if(_faqs_questions["faqs_question[" + mapping.SrcValue + "]"] != faq.faqs_questions["faqs_question[" + mapping.DestValue + "]"])
							{
								return false;
							}
							
							if(_faqs_answers["faqs_answer[" + mapping.SrcValue + "]"] != faq.faqs_answers["faqs_answer[" + mapping.DestValue + "]"])
							{
								return false;
							}	
							
							if(_faqs_urls["faqs_url[" + mapping.SrcValue + "]"] != faq.faqs_urls["faqs_url[" + mapping.DestValue + "]"])
							{
								return false;
							}														
						}
						catch(KeyNotFoundException ex)
						{
							throw ex;
						}
					}
					return true;
				}
			}
			
			return false;
		}
    	
        public Faq()
        {
        }

        public Faq(string json)
         : this(JObject.Parse(json))
        {
        }

        private JObject __jobject;
        public Faq(JObject obj)
        {
            this.__jobject = obj;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        private FaqStore store;

        public FaqStore Store
        {
           get{
            return store;}
           set{
            store = value;}
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_id;
        public string faqs_id
        {
            get
            {
                if(_faqs_id == null)
                    _faqs_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_id"));
                return _faqs_id;
            }
            set
            {
                _faqs_id = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_status;
        public string faqs_status
        {
            get
            {
                if(_faqs_status == null)
                    _faqs_status = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_status"));
                return _faqs_status;
            }
            set
            {
                _faqs_status = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_order;
        public string faqs_order
        {
            get
            {
                if(_faqs_order == null)
                    _faqs_order = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_order"));
                return _faqs_order;
            }
            set
            {
                _faqs_order = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_date_added;
        public string faqs_date_added
        {
            get
            {
                if(_faqs_date_added == null)
                    _faqs_date_added = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_date_added"));
                return _faqs_date_added;
            }
            set
            {
                _faqs_date_added = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_last_modified;
        public string faqs_last_modified
        {
            get
            {
                if(_faqs_last_modified == null)
                    _faqs_last_modified = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_last_modified"));
                return _faqs_last_modified;
            }
            set
            {
                _faqs_last_modified = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _language_id;
        public string language_id
        {
            get
            {
                if(_language_id == null)
                    _language_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "language_id"));
                return _language_id;
            }
            set
            {
                _language_id = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_question;
        public string faqs_question
        {
            get
            {
                if(_faqs_question == null)
                    _faqs_question = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_question"));
                return _faqs_question;
            }
            set
            {
                _faqs_question = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_url;
        public string faqs_url
        {
            get
            {
                if(_faqs_url == null)
                    _faqs_url = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_url"));
                return _faqs_url;
            }
            set
            {
                _faqs_url = value;
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private string _faqs_answer;
        public string faqs_answer
        {
            get
            {
                if(_faqs_answer == null)
                    _faqs_answer = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "faqs_answer"));
                return _faqs_answer;
            }
            set
            {
                _faqs_answer = value;
            }
        }        
        
        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private Dictionary<string, string> _faqs_questions;
		public Dictionary<string, string> faqs_questions
		{
			get
			{
				if(_faqs_questions == null)
				{
					_faqs_questions = new Dictionary<string, string>();
					
					if(__jobject != null)
					{
						if(store != null)
						{
							var languages = store.site.GetLanguageStore().LoadItems();
							
							foreach(Language language in languages)
							{
								_faqs_questions["faqs_question[" + language.languages_id + "]"] = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject,"faqs_question[" + language.languages_id + "]"));
							}
						}
					}
				}
				
				return _faqs_questions;
			}
			set
			{
				_faqs_questions = value;
			}
		}
        
        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private Dictionary<string, string> _faqs_urls;
		public Dictionary<string, string> faqs_urls
		{
			get
			{
				if(_faqs_urls == null)
				{
					_faqs_urls = new Dictionary<string, string>();
					
					if(__jobject != null)
					{
						if(store != null)
						{
							var languages = store.site.GetLanguageStore().LoadItems();
							
							foreach(Language language in languages)
							{
								_faqs_urls["faqs_url[" + language.languages_id + "]"] = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject,"faqs_url[" + language.languages_id + "]"));
							}
						}
					}
				}
				
				return _faqs_urls;
			}
			set
			{
				_faqs_urls = value;
			}
		}
        
        private Dictionary<string, string> _faqs_answers;
		public Dictionary<string, string> faqs_answers
		{
			get
			{
				if(_faqs_answers == null)
				{
					_faqs_answers = new Dictionary<string, string>();
					
					if(__jobject != null)
					{
						if(store != null)
						{
							var languages = store.site.GetLanguageStore().LoadItems();
							
							foreach(Language language in languages)
							{
								_faqs_answers["faqs_answer[" + language.languages_id + "]"] = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject,"faqs_answer[" + language.languages_id + "]"));
							}
						}
					}
				}
				
				return _faqs_answers;
			}
			set
			{
				_faqs_answers = value;
			}
		}

    }
}
